/*
 * @Author: 吴世扬 18368095041@163.com
 * @Date: 2024-09-05 09:45:28
 * @LastEditors: 吴世扬 18368095041@163.com
 * @LastEditTime: 2024-10-14 11:15:18
 * @FilePath: /react18-vite-admin/src/api/department.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

import { service } from '@/service/app/useRequest';
import { DeptTreeItem } from '@/typings/api/department';

export const readDeptTree = () => {
    return service<HttpResult<DeptTreeItem[]>>({
        url: `/admin/api/department/tree`,
        method: 'get'
    }).then((res) => {
        return res.data;
    });
};

export class DeptParam {
    id?: number;
    name = '';
    parentId?: number;
    valid = true;
}

export const createOrUpdateDept = (data: DeptParam) => {
    return service<HttpResult>({
        url: '/admin/api/department/save',
        method: 'post',
        data
    }).then((res) => {
        return res.data;
    });
};
